<?php
namespace app\api\controller\v1;

use app\api\controller\Base;
use app\api\model\Theme as ThemeModel;
use app\api\validate\IdCollection;
use app\lib\exception\MissEx;
use app\api\validate\IdMPot;
/** 
* Document
*/
class Theme extends Base {
    

    /**
     * 获取简单的主题信息列表
     *
     * @param string $ids
     * @return void
     */
    public function getSimpleList($ids=null){
        (new IdCollection())->goCheck();
        
        $themes = ThemeModel::all($ids);
        
        if(empty($themes)) throw new MissEx('请求的专题不存在',30002);
        // 转化图片绝对地址
        foreach ($themes as $theme) {
            $simpleInfo = $theme->toArray();
            $simpleInfo['topic_img'] = $theme->topic_img;
            $res[] = $simpleInfo;
        }
        
        return $this->data($res);
    }
    /**
     * 获取一个专题的详细信息
     *
     * @param int|string $id
     * @return void
     */
    public function getOne($id){
        (new IdMPot())->goCheck();

        $res = ThemeModel::getCompleteInfo($id);
        
        if(empty($res)) throw new MissEx('请求的专题不存在',30002);
        
        return $this->data($res);
    }
    // public function (){
    // }
}